<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@ page import="java.util.*"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%!@SuppressWarnings("unchecked")%>
<html:html>
<head>
<script type="text/javascript">
	function submitForm(residence) {
		document.residenceForm.residence.value = residence;
		document.residenceForm.submit();
	}
</script>
<title>Country of residence</title>
</head>
<body>
	<bean:write name="nameForm" property="firstName" scope="session" />
	<bean:write name="nameForm" property="middleInit" scope="session" />
	<bean:write name="nameForm" property="lastName" scope="session" />
	<br>
	<bean:write name="citizenshipForm" property="citizenship"
		scope="session" />
	<br>
	<%
		String citizenship = (String) request
					.getParameter("citizenship");
			String path = "javascript:submitForm('" + citizenship + "')";
	%>

	<html:link href="<%=path%>">
					Same with country of citizenship
				</html:link>
	<%
		Vector<String> countries = (Vector<String>) request
					.getAttribute("countries");
	%>
	<table border=0>
		<tr>
			<%
				for (int i = 0; i < countries.size(); i++) {
						if (i % 3 == 0)
							out.println("</tr><tr>");
			%>
			<%
				path = "javascript:submitForm('" + countries.get(i) + "')";
			%>
			<td><html:link href="<%=path%>">
					<%=countries.get(i)%>
				</html:link>
			</td>
			<%
				}
			%>
		</tr>
	</table>
	<html:form action="/residence" method="POST">
		<html:hidden property="residence" />
	</html:form>
</body>
</html:html>